#include <iostream>
#include <limits.h>
#include <algorithm>
#include "SortTestHelper.h"
#include "Student.h"


using namespace std;

template<typename T>
void selectionSort(T arr[] , int n ){

    for(int i = 0 ; i < n ; i++){

        //寻找[i ,  n ] 区间里的最小值
        int minIndex = i ;
        for ( int j = i + 1 ; j < n ; j++){
            if ( arr[j] < arr[minIndex])
                minIndex = j ;
        }
        swap( arr[i] , arr[minIndex]);
    }

}

int main1(){

    int n =10000;
    int *arr = SortTestHelper::generateRandomArray(n,0,n);


    SortTestHelper::testSort("selectSort",selectionSort,arr,n);
    delete[] arr;


}

int main() {

    int n =10000;
   int *arr = SortTestHelper::generateRandomArray(n,0,n);

//    SortTestHelper::printArray(arr,n);

    delete[] arr;

    int a[10] = {10,923,8,7,6,5,42,3,2,1};


    selectionSort(a,10);
    SortTestHelper::printArray(a,10);


    cout << SortTestHelper::isSort(a,10) << endl;



    float b[10] = {10,9,8,7,6,5,4,3,2,1};
    selectionSort(b,10);
    SortTestHelper::printArray(b,10);

    string c[10] = {"a","b","a","e","f","g","h","i","m","l"};
    string e[10] = {"a","b","a","e","f","g","h","i","m","l"};
    selectionSort(c,10);
    SortTestHelper::printArray(c,10);

    Student d[4] = { {"D",90} , {"C" , 100} , {"B",95} ,{"A",95}};
    selectionSort(d,4);
    SortTestHelper::printArray(d,4);

    delete[] a,b,c,d,e;

    return 0;
}


//int main(){
//
//    int a = INT_MIN;
//
//    cout << a << endl;
//
//
//}